package com.rds.web.controller.pms;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rds.common.annotation.Log;
import com.rds.common.enums.BusinessType;
import com.rds.system.domain.RdaFormDetails;
import com.rds.system.service.IRdaFormDetailsService;
import com.rds.common.core.controller.BaseController;
import com.rds.common.core.domain.AjaxResult;
import com.rds.common.utils.poi.ExcelUtil;
import com.rds.common.core.page.TableDataInfo;

/**
 * form表单列Controller
 *
 * @author rds
 * @date 2021-04-19
 */
@RestController
@RequestMapping("/pms/formDetails")
public class RdaFormDetailsController extends BaseController
{
    @Autowired
    private IRdaFormDetailsService rdaFormDetailsService;

    /**
     * 查询form表单列列表
     */
    @PreAuthorize("@ss.hasPermi('pms:form:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdaFormDetails rdaFormDetails)
    {
        startPage();
        List<RdaFormDetails> list = rdaFormDetailsService.selectRdaFormDetailsList(rdaFormDetails);
        return getDataTable(list);
    }

    /**
     * 导出form表单列列表
     */
    @PreAuthorize("@ss.hasPermi('pms:details:export')")
    @Log(title = "form表单列", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RdaFormDetails rdaFormDetails)
    {
        List<RdaFormDetails> list = rdaFormDetailsService.selectRdaFormDetailsList(rdaFormDetails);
        ExcelUtil<RdaFormDetails> util = new ExcelUtil<RdaFormDetails>(RdaFormDetails.class);
        return util.exportExcel(list, "details");
    }

    /**
     * 获取form表单列详细信息
     */
    @PreAuthorize("@ss.hasPermi('pms:details:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rdaFormDetailsService.selectRdaFormDetailsById(id));
    }

    /**
     * 新增form表单列
     */
    @PreAuthorize("@ss.hasPermi('pms:details:add')")
    @Log(title = "form表单列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdaFormDetails rdaFormDetails)
    {
        return toAjax(rdaFormDetailsService.insertRdaFormDetails(rdaFormDetails));
    }

    /**
     * 修改form表单列
     */
    @PreAuthorize("@ss.hasPermi('pms:details:edit')")
    @Log(title = "form表单列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdaFormDetails rdaFormDetails)
    {
        return toAjax(rdaFormDetailsService.updateRdaFormDetails(rdaFormDetails));
    }

    /**
     * 删除form表单列
     */
    @PreAuthorize("@ss.hasPermi('pms:details:remove')")
    @Log(title = "form表单列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdaFormDetailsService.deleteRdaFormDetailsByIds(ids));
    }
}
